﻿app.controller("systray", ["$scope", function ($scope) {
    $scope.enabled = false;
    $scope.signalrConnected = false;
    $scope.brokenWidgets = {};

    $scope.$on("signalr.statechanged", function (event, args) {
        var stateLookup = {
            0: "connecting",
            1: "connected",
            2: "reconnecting",
            4: "disconnected"
        };

        console.log("SignalR state: " + stateLookup[args.oldState] + "->" + stateLookup[args.newState]);
        $scope.signalrConnected = (args.newState === 1);
    });

    $scope.$on("systray.enabled", function(event, args) {
        $scope.enabled = args;
    });
    $scope.$on("widget.update-failed", function (event, args) {
        console.log("widget.update-failed: " + args);
        $scope.brokenWidgets = args;
    });
    $scope.$on("widget.update-fixed", function (event, args) {
        console.log("widget.update-fixed: " + args);
        $scope.brokenWidgets = args;
    });
}]);